#include <bits/stdc++.h>
#include "../../tools/tools.h"
using namespace std;

constexpr int INF = 0x7fffffff; // 无穷大
typedef long long ll;


class Solution {
public:
    string clearDigits(string s) {
        vector<int> idxs;
        unordered_set<int> dels;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] <= '9' && s[i] >= '0') {
                dels.insert(i);
                dels.insert(idxs.back());
                idxs.pop_back();
            }else {
                idxs.push_back(i);
            }
        }
        string ans;
        for(int i = 0; i < s.size(); i++) {
            if(dels.contains(i))continue;
            ans.push_back(s[i]);
        }
        return ans;
    }
};

int main(int argc, const char** argv) {
    Solution s;
    cout<<s.clearDigits("abc") << endl;
    cout<<s.clearDigits("cd34") << endl;
    cout<<s.clearDigits("hfsj4k62lda") << endl;
    return 0;
}
